import pytest,mysql


DB_CONFIG = {
    "host": "10.59.9.24",
    "port": 3306,
    "user": "wms",
    "password": "Wms123456!",
    "database": "wms"
}

def db_connection():
    """创建并返回数据库连接"""

    try:
        connection = mysql.connector.connect(**DB_CONFIG)
        yield connection
        connection.close()
    except Exception as e:
        pytest.fail(f"无法连接到数据库：{e}")